# Author: Sanmu
# CreatTime: 2024/10/25
# Descriptior: 客户信息页
from sympy.polys.ring_series import rs_tan

from base_page.base_page import BasePage


class CustomerPage(BasePage):
    # 新增
    add_button = ('xpath','//span[text()="新增"]/..')
    by_title = ('id', 'supplier')
    by_contacts = ('id', 'contacts')
    by_telephone = ('id', 'telephone')
    by_phoneNum = ('id', 'phoneNum')
    save_button = ('xpath', '//span[text()="保 存"]/..')
    # 删除
    delete_a = ('link text', '删除')
    ant_btn = ('xpath','//span[text()="确 定"]/..')
    # 启用
    # 禁用

    # 打开客户信息页
    def open_url(self,path):
        self.open(path)
        self.wait(2)

    # 新增操作
    def add_customer(self, title, contacts, telephone, phonenum):
        self.click(*self.add_button)
        self.input(*self.by_title, title)
        self.input(*self.by_contacts, contacts)
        self.input(*self.by_telephone, telephone)
        self.input(*self.by_phoneNum, phonenum)
        self.click(*self.save_button)
        self.wait(2)
    # 删除操作
    def dele_customer(self):
        while True:
            try:
                self.click(*self.delete_a)
                self.wait(2)
                self.click(*self.ant_btn)
                self.wait(2)
            except:
                return False


